package com.qc.ds.util;

import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PropertieUtil {

	private static Logger logger = LoggerFactory.getLogger(PropertieUtil.class);

	private static Properties props;

	static {
		String fileName = "dianshagn.properties";
		props = new Properties();
		try {
			props.load(new InputStreamReader(PropertieUtil.class.getClassLoader().getResourceAsStream(fileName), "UTF-8"));
		} catch (IOException e) {
			logger.error("配置文件读取异常", e);
		}
	}
	
	
	public static String getProperty(String key, String defaultValue) {
		String value = props.getProperty(key.trim());
		if (StringUtils.isBlank(value)) {
			value = defaultValue;
		}
		return value;
	}

}
